define(function (require, exports, module) {
    var $ = require('jquery');
    var dialog = require("dialog");

    return {
        /**
         * 弹层要求输入手机号码
         * @param {{ok:function(string):cancel:function=}} config
         */
        showMobileInputDialog: function (config) {
            var title = "添加手机号";
            var str = '<div style="margin-left:30px;margin-top:10px;" class="clearfix lh30"><label class="fl">手机号码：</label>'
                + '<div class="fl"><input class="input-text" style="width:220px;" text="text" maxlength="11" value="" id="new_tel" />'
                + '<div class="c-red f13 js-err"></div></div></div>';

            var d = dialog({
                title: title,
                content: str,
                fixed: true,
                width: 400,
                height: 60,
                okValue: "保存",
                ok: function () {
                    var $content = this._$('content');
                    var $input = $content.find("input");
                    var $err = $content.find(".js-err");
                    var mobile = $.trim($input.val());
                    if (mobile) {
                        $err.html("");
                        if (/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile) == false) {
                            $err.html("请输入正确的11位手机号");
                            $input.focus();
                            return false;
                        }
                        config.ok && config.ok(mobile);
                        return true;
                    } else {
                        $err.html("请输入手机号");
                        $input.focus();
                        return false;
                    }
                },
                cancel: config.cancel
            });
            d.showModal();
        }
    }
});